package homework;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class TCP_DictServer extends TCP_EchoSever {
    private Map<String,String> dict = new HashMap<>();

    public TCP_DictServer(int port) throws IOException {
        super(port);

        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
        dict.put("bird", "小鸟");
        dict.put("fish", "鱼");
        dict.put("pig", "猪");
        dict.put("man", "男人");
        dict.put("woman", "女人");
        dict.put("good", "好的");
        dict.put("bad", "不好");
        dict.put("chicken", "小鸡");
    }
    @Override
    public String process(String request){
        return dict.getOrDefault(request,"该单词没有查到");
    }

    public static void main(String[] args) throws IOException {
        TCP_DictServer dictServer = new TCP_DictServer(9090);
        dictServer.start();
    }

}
